package com.jeez.module.sys.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import com.jeez.common.entity.DataEntity;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.sql.Timestamp;
import java.util.List;

/**
 * @author: Felix
 * @date: 2018-7-1
 * @version: v1.0
 * @description:
 */
@Entity
@Table(name = "t_sys_role")
@Getter
@Setter
public class SysRole extends DataEntity<SysRole> {
    /**
     * 角色名称
     */
    @NotNull(message="角色名不能为空")
    @Length(min=1, max=60, message="角色名长度必须介于 1 和 60 之间")
    @Basic
    @Column(name = "role_name", length = 60)
    private String roleName;

    /**
     * 角色编码
     */
    @NotNull(message="角色编码不能为空")
    @Length(min=1, max=60, message="角色编码长度必须介于 1 和 60 之间")
    @Basic
    @Column(name = "role_code", length = 60)
    private String roleCode;

    @Basic
    @Column(name = "org_id", nullable = true, insertable = true, updatable = true)
    private Long orgId;

    /**
     * 是否系统角色
     */
    @Basic
    @Column(name = "is_sys_role", length = 1)
    private boolean sysRole = false;

    /**
     * 是否管理员
     */
    @Basic
    @Column(name = "is_admin_role", length = 1)
    private boolean adminRole = false;

    /**
     * 备注
     */
    @Basic
    @Column(name = "remark", nullable = true, insertable = true, updatable = true, length = 400)
    private String remark;

    /**
     * 状态: 1正常; 0禁用
     */
    @Basic
    @Column(name = "status", length = 10)
    private String status = "1";

    @ManyToMany(mappedBy = "roles")
    @JsonIgnore
    private List<SysUser> users = Lists.newArrayList();

    @ManyToMany(mappedBy = "roles")
    @JsonIgnore
    private List<SysMenu> menus = Lists.newArrayList();

}
